#include "s3c24xx.h"
#include "mini2440.h"

void eint_handle (void)
{
    unsigned long oft = INTOFFSET;
    unsigned long val = EINTPEND;

    switch (oft) {
    case 5: /* EINT8_23 */
        GPBDAT |= 0x0f << 5; // turn off all leds

        EINTPEND |= (1<<8)|(1<<11)|(1<<13)|(1<<14)|(1<<15)|(1<<19);    //clear eint 11,19
        EINTMASK &= ~((1<<8)|(1<<11)|(1<<13)|(1<<14)|(1<<15)|(1<<19)); //enable eint11,19

        if (val & 1<<KEY0_INT) {
            GPBDAT &= ~(1<<LED0);
        }
        if (val & 1<<KEY1_INT) {
            GPBDAT &= ~(1<<LED1);
        }
        if (val & 1<<KEY2_INT) {
           GPBDAT &= ~(1<<LED2);
        }
        if (val & 1<<KEY3_INT) {
            GPBDAT &= ~(1<<LED3);
        }
        if (val & 1<<KEY4_INT) {
            GPBDAT &= ~(1<<LED0) & ~(1<<LED1);
        }
        if (val & 1<<KEY5_INT) {
            GPBDAT &= ~(1<<LED2) & ~(1<<LED3);
        }
        break;
    default:
        break;
    }

    SRCPND = 1 << oft;
    INTPND = 1 << oft;
}
